Clonenode is a method on the htmlelement prototype chain. It is used to create a copy of a specified Dom node. It accepts a Boolean parameter include_all. If include_all is set to true, the copy carries all the child nodes of the specified node.
Some incredible bugs were found during the development of Baidu's "crack special effects". The first reaction was that the code of the special effects conflicted with the original script on the page. After debugging, it was found that, the problem
CloneNode is a method on the HtmlElement prototype chain that creates a copy of the specified DOM node, accepts a Boolean parameter Include_all, and if Include_all is set to True, the copy takes all the child nodes of the specified node.
However,
True: Completely copying a node. What is "complete" means copying everything, including its subnodes, so that all the text nodes and all others are cloned.False: only the current node is cloned. No child node is cloned. Of course, the wrapped text
True: Completely copy a node, what is called complete, is to copy everything, including his child nodes, so that text nodes, all of which are cloned, the so-called complete
False: Clones only the current node, does not clone any child nodes, and of
In many cases, we use for to generate multiple node structures with the same structure, so we need to write a lot of code such as createElement, setAttribute, and appendChild.However, we only need an html template to clone existing nodes, including
In many cases, we need to use HTMLDOM to dynamically generate many identical nodes with JavaScript, including its subnodes. In many cases, we use for to generate multiple node structures with the same structure, in this way, we need to write a lot
In many cases, we need to use HTMLDOM to dynamically generate many identical nodes with JavaScript, including its subnodes. In many cases, we use for to generate multiple node structures with the same structure, in this way, we need to write a lot
This article mainly introduces how to use the copy node cloneNode () for javascript node operations. If you need it, refer to the cloneNode (a) method to accept a Boolean parameter, indicating whether to perform deep copy.
True: Performs deep copy
Example of cloneNode () usage of DOM node deep clone function
This article mainly introduces the usage of the DOM node deep clone function cloneNode (). The instance analyzes the operation skills of the cloneNode () function deep copy, which has
This article mainly introduces the usage of the DOM node deep clone function cloneNode (), and analyzes the operation skills of the cloneNode () function deep replication, which has some reference value, for more information about how to use the DOM
I think this method is not a private Implementation of IE. It can achieve perfect copy in IE, And the other seems to be a little strong, it is similar to the replacenode naming method.
In IE, clonenode can copy all attributes, attributes, and
Many times we use a for to generate multiple structures with the same structure, so we need to write a lot of createelement, setattribute, appendchild code.But in fact we only need to have an HTML template, we can use the CloneNode method to clone
DOM node deep clone function cloneNode () usage instance, domclonenode
This example describes how to use the DOM node deep clone function cloneNode. Share it with you for your reference.
The specific implementation method is as follows:Copy
This article mainly introduced the JavaScript node operation copy node CloneNode () The use, needs the friend may refer to underThe CloneNode (a) method accepts a Boolean parameter that indicates whether a deep copy is true: A deep copy is performed,
The CloneNode (a) method accepts a Boolean parameter that indicates whether a deep copy
True: Performs a deep copy, copying this node and the entire child node tree.
False: Shallow copy. Only the node itself is replicated.
The copy of the node
This article describes the DOM node depth cloning function clonenode () usage. Share to everyone for your reference.
The implementation methods are as follows:
Copy Code code as follows:
Spring
Summer
DOM (DocumentObjectModel) is a Document Object Model. APIs for HTML and XML documents (application interfaces) are provided ). This article introduces the common APIs for javascript operations on dom. If you are interested in javascriptdomapi, join
DOM method
Create a node: the basic purpose of the following DOM method is to create a new node.
Createelement ():
The createelement () method creates a new element node based on the given tag name. The return value of this method is a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.